package com.example.scoprimi;


import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.DialogInterface;
import android.graphics.Typeface;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewConfiguration;
import android.view.WindowManager;
import android.widget.SeekBar;
import android.widget.SeekBar.OnSeekBarChangeListener;
import android.widget.TextView;
import android.widget.Toast;

public class Trova extends Activity {
	 
    private SeekBar volumeControl = null;
    
    
 
    @SuppressLint("NewApi")
	@Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.trova);
        getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
		getOverflowMenu();
		
	    getActionBar().setDisplayHomeAsUpEnabled(true);
	    setTitle("");
	    getActionBar().setIcon(R.drawable.ic_home_up);
        //FontHelper.applyFont(this, findViewById(R.id.home), "fonts/Greyscale.ttf");
        
        //TextView text = (TextView) findViewById(R.id.testotrova);
        //Typeface font = Typeface.createFromAsset(getAssets(), "Greyscale.ttf");  
        //text.setTypeface(font);
        //TextView text2 = (TextView) findViewById(R.id.titolobarra);
        //Typeface font2 = Typeface.createFromAsset(getAssets(), "Greyscale.ttf");  
        //text.setTypeface(font2);
        //SeekBar text2 = (SeekBar) findViewById(R.id.titolobarra);
        //Typeface font2 = Typeface.createFromAsset(getAssets(), "Greyscale.ttf");  
        //text.setTypeface(font2);
        //SeekBar text3 = (SeekBar) findViewById(R.id.titolobarra2);
        //Typeface font3 = Typeface.createFromAsset(getAssets(), "Greyscale.ttf");  
        //text.setTypeface(font3);
 
        volumeControl = (SeekBar) findViewById(R.id.volume_bar);
 
        volumeControl.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
            int progressChanged = 3;
 
            public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser){
                progressChanged = progress;
            }
 
            public void onStartTrackingTouch(SeekBar seekBar) {
                // TODO Auto-generated method stub
            }
 
            public void onStopTrackingTouch(SeekBar seekBar) {
                Toast.makeText(Trova.this,"Valore ceh passa:"+progressChanged, 
                        Toast.LENGTH_SHORT).show();
            }
        });
        
        volumeControl = (SeekBar) findViewById(R.id.volume_bar2);
        
        volumeControl.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
            int progressChanged = 3;
 
            public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser){
                progressChanged = progress;
            }
 
            public void onStartTrackingTouch(SeekBar seekBar) {
                // TODO Auto-generated method stub
            }
 
            public void onStopTrackingTouch(SeekBar seekBar) {
                Toast.makeText(Trova.this,"Valore ceh passa:"+progressChanged, 
                        Toast.LENGTH_SHORT).show();
            }
        });
        
        volumeControl = (SeekBar) findViewById(R.id.volume_bar3);
        
        volumeControl.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
            int progressChanged = 3;
 
            public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser){
                progressChanged = progress;
            }
 
            public void onStartTrackingTouch(SeekBar seekBar) {
                // TODO Auto-generated method stub
            }
 
            public void onStopTrackingTouch(SeekBar seekBar) {
                Toast.makeText(Trova.this,"Valore ceh passa:"+progressChanged, 
                        Toast.LENGTH_SHORT).show();
            }
        });
        
        volumeControl = (SeekBar) findViewById(R.id.volume_bar4);
        
        volumeControl.setOnSeekBarChangeListener(new OnSeekBarChangeListener() {
            int progressChanged = 3;
 
            public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser){
                progressChanged = progress;
            }
 
            public void onStartTrackingTouch(SeekBar seekBar) {
                // TODO Auto-generated method stub
            }
 
            public void onStopTrackingTouch(SeekBar seekBar) {
                Toast.makeText(Trova.this,"Valore ceh passa:"+progressChanged, 
                        Toast.LENGTH_SHORT).show();
            }
        });
 
    }
 
    
    
 // inflate for action bar
 	@Override
 	public boolean onCreateOptionsMenu(Menu menu) {
 		// Inflate the menu; this adds items to the action bar if it is present.
 		getMenuInflater().inflate(R.menu.main3, menu);
 		return true;
 	}
 	
 	// handle click events for action bar items
 	@Override
 	public boolean onOptionsItemSelected(MenuItem item) {

 	    switch (item.getItemId()) {
 	    
 	        /*case R.id.action_search:
 	            showToast("Tasto cerca");
 	            return true;
 	            
 	        case R.id.action_settings:
 	        	showToast("Tasto settings");
 	            return true;*/
 	            
 	        //case R.id.share:
 	        //	showToast("Share was clicked.");
 	        //   return true;
 	            
 	        case android.R.id.home:
 	        	this.finish();
 	            return true;
 	        default:
 	            return super.onOptionsItemSelected(item);
 	            
 	        
 	            
 	        
 	    }
 	}
 	
 	// put the other two menu on the three dots (overflow)
 	private void getOverflowMenu() {

 	    try {
 	    	
 	       ViewConfiguration config = ViewConfiguration.get(this);
 	       java.lang.reflect.Field menuKeyField = ViewConfiguration.class.getDeclaredField("sHasPermanentMenuKey");
 	       if(menuKeyField != null) {
 	           menuKeyField.setAccessible(true);
 	           menuKeyField.setBoolean(config, false);
 	       }
 	   } catch (Exception e) {
 	       e.printStackTrace();
 	   }
 	    
 	 }
 	
 	// so that we know something was triggered
 	public void showToast(String msg){
 		Toast.makeText(this, msg, Toast.LENGTH_SHORT).show();
 	}
 
}
